<template>
  <!-- 登录注册 -->
  <div class="loginContainer">
    <div class="loginInner">
      <div class="login_header">
        <div class="login_header_title">
          <!-- 让页面不要跳转 -->
          <a
            href="javascript:;"
            :class="{ on: loginWay }"
            @click="loginWay = true"
            >短信登录</a
          >
          <a
            href="javascript:;"
            :class="{ on: !loginWay }"
            @click="loginWay = false"
            >密码登录</a
          >
        </div>
      </div>
      <!-- 内容部分 -->
      <div class="login_content">
        <!-- 这段代码.prevent 表示提交以后不刷新页面 submit点击默认行为是提交表单，不需要它提交,只需要执行addMemo方法 -->
        <form @submit.prevent="login">
          <!-- 短信登录 -->
          <div :class="{ on: loginWay }" class="loginform">
            <section class="login_message">
              <input
                type="tel"
                placeholder="手机号"
                v-model="phone"
              />
              <button
                class="get_verification"
                @click.prevent="getCode"
              >
                {{"获取验证码"}}
              </button>
            </section>
            <section class="login_verification">
              <input
                type="tel"
                maxlength="4"
                placeholder="验证码"
                v-model="code"
              />
            </section>
            <section class="login_hint">
              温馨提示：登录即表示您已阅读、理解并同意<br />
              <a href="javascript:;">《用户服务协议》</a>
              <!-- <button class="login_submit" @click="login_submit">登录</button> -->
            </section>
          </div>
          <!-- 密码登录 -->
          <div :class="{ on: !loginWay }" class="loginform">
            <section class="login_message">
              <input
                type="tel"
                placeholder="手机号"
                v-model="name"
              />
            </section>
            <section class="login_verification">
              <input
                type="text"
                placeholder="密码"
                v-if="showPwd"
                v-model="pwd"
              />
              <input
                type="password"
                placeholder="密码"
                v-else
                v-model="pwd"
              />
              <section
                class="switch_button"
                :class="showPwd ? 'on' : 'off'"
                @click="showPwd = !showPwd"
              >
                <section
                  class="switch_circle"
                  :class="{ right: showPwd }"
                ></section>
                <section class="switch_text">
                  {{ showPwd ? "abc" : "...." }}
                </section>
              </section>
            </section>
            <div class="forgetPwd">
              <router-link to="/forgetpwd"><a>忘记密码</a></router-link>
            </div>
          </div>
        </form>
      </div>
      <button class="login_submit">登录</button>
    </div>
    <div class="register">
      没有账号？<router-link to="/register"><a>立即注册</a></router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      loginWay: true, //true代表短信登陆, false代表密码
      phone: "", //手机号,
      code: "", //验证码
      timer: null,
      showPwd: false,
      pwd: "",
      name,
    };
  },
  computed: {

  },
  methods: {
    login_submit() {
      this.login();
    },
    getCode() {
	  alert('验证码是：1234')
    },
  },
};
</script>

<style scoped>
.loginContainer {
  width: 100%;
  height: 100%;
  background: #fff;
}

.loginInner {
  width: 80%;
  margin: 0 auto;
  padding-top: 60px;
}

.loginInner .login_header .login_logo {
  color: #0faeff;
  font-weight: bolder;
  font-size: 40px;
  text-align: center;
}

.login_header .login_header_title {
  text-align: center;
  padding-top: 40px;
}

.login_header_title a {
  text-decoration: none;
  font-size: 14px;
  color: #333;
  padding-bottom: 4px;
}

.login_header_title a:first-child {
  margin-right: 40px;
}

.login_header_title a.on {
  color: #0faeff;
  font-weight: bolder;
  border-bottom: 2px solid #0faeff;
}
.login_content form .loginform {
  display: none;
}

.login_content form .loginform.on {
  display: block;
}

.login_content form input {
  width: 100%;
  height: 100%;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
  padding-left: 10px;
  box-sizing: border-box;
}

.login_content form input:focus {
  border: 1px solid #0faeff;
}
.login_message {
  position: relative;
  margin-top: 16px;
  height: 48px;
  font-size: 14px;
  background: #fff;
}

.login_message .get_verification {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  border: none;
  color: #ccc;
  background: transparent;
  font-size: 14px;
}

.login_message .get_verification.right_phone {
  color: #000;
}

.login_hint {
  text-align: center;
  color: #999;
  margin-top: 12px;
  font-size: 14px;
  line-height: 20px;
}

.login_hint a {
  text-decoration: none;
  color: #0faeff;
}

.login_verification {
  position: relative;
  margin-top: 16px;
  height: 48px;
  font-size: 14px;
  background: #fff;
}

.login_verification .switch_button {
  border: 1px solid #ddd;
  width: 30px;
  height: 16px;
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  border-radius: 8px;
  padding: 0 6px;
  line-height: 16px;
  font-size: 12px;
  transition: background-color 0.3s;
}

.login_verification .switch_button.on {
  background: #0faeff;
}

.login_verification .switch_button.off {
  background: #fff;
}
.switch_button .switch_circle {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  position: absolute;
  left: -1px;
  top: -1px;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
}

.switch_button .switch_circle.right {
  transform: translateX(30px);
}

.switch_button .switch_text {
  color: #ddd;
  float: right;
}

.login_submit {
  display: block;
  width: 100%;
  height: 42px;
  margin-top: 30px;
  background: #0faeff;
  border-radius: 4px;
  font-size: 16px;
  line-height: 42px;
  color: #fff;
  text-align: center;
  border: none;
}
.register {
  font-size: 14px;
  color: #999;
  position: fixed;
  bottom: 20px;
  width: 100%;
  text-align: center;
}
.register a {
  text-decoration: none;
  color: #0faeff;
}
.forgetPwd {
  text-align: right;
  font-size: 14px;
  padding-top: 15px;
}
.forgetPwd a {
  text-decoration: none;
  color: #0faeff;
}
</style>